package com.itheima.chapter08.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

//Collection集合存储学生对象并遍历
public class Case {
    public static void main(String[] args) {
        Student s =new Student("zhangsan",23);
        Student s2 =new Student("lisi",26);
        Student s3 =new Student("wangwu",31);
        Collection<Student> list = new ArrayList<>();
        list.add(s);
        list.add(s2);
        list.add(s3);
        for (Student student : list) {
            System.out.println(student);
        }
        System.out.println("---------");
        Iterator<Student> it = list.iterator();
        while(it.hasNext()){
            Student next = it.next();
            System.out.println(next);
        }
    }
}
